package com.zuoshengli.service.impl;

import com.zuoshengli.api.StockService;
import com.zuoshengli.dao.StockMapper;
import com.zuoshengli.pojo.Stock;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description TODO
 * @Author zuoshengli
 **/
@Service(version = "${demo.service.version}")
public class StockServiceImpl implements StockService {

    @Autowired
    private StockMapper stockMapper;

    @Override
    public int getStockCount(int id) {
        Stock stock = stockMapper.selectByPrimaryKey(id);
        return stock.getCount();
    }

    @Override
    public Stock getStockById(int id) {
        return stockMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateStockById(Stock stock) {
        return stockMapper.updateByPrimaryKeySelective(stock);
    }

    @Override
    public int updateStockByOptimistic(Stock stock) {
        return stockMapper.updateStockByOptimistic(stock);
    }
}
